package com.lvmama.rhino.pojo.comment.Enum;

/**
 * @Author:caoyong
 * @Description:
 * @Date：2017/9/29
 */
public enum CommentDateRangeEnum {
    THREE_DAY(0, 3, "三天内"),
    WEEK(3,7,"一周内"),
    MONTH(7,31,"一个月内"),
    THREE_MONTH(31,92,"三个月内"),
    OVER_THREE_MONTH(92,365,"三个月以上");

    CommentDateRangeEnum(Integer start, Integer end, String name) {
        this.start = start;
        this.end = end;
        this.name = name;
    }

    private Integer start;
    private Integer end;
    private String name;

    public Integer getStart() {
        return start;
    }

    public Integer getEnd() {
        return end;
    }

    public String getName() {
        return name;
    }
    /**
     * 根据end获取枚举
     * @param end
     * @return
     */
    public static CommentDateRangeEnum getEnum(Integer end){
        for(CommentDateRangeEnum en : CommentDateRangeEnum.values()){
            if(en.getEnd().equals(end)){
                return en;
            }
        }
        return null;
    }
    /**
     * 根据name获取枚举
     * @param name
     * @return
     */
    public static CommentDateRangeEnum getEnumByName(String name){
        for(CommentDateRangeEnum en : CommentDateRangeEnum.values()){
            if(en.getName().equals(name)){
                return en;
            }
        }
        return null;
    }
}
